package finalhadoop;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;

/**
 * Partitions key based on "natural" key 
 */
public class NaturalKeyPartitioner extends Partitioner<WordKey, Text> {

	@Override
	public int getPartition(WordKey key, Text val, int numPartitions) {
		int hash = key.getSymbol().hashCode();
		int partition = hash % numPartitions;
		return Math.abs(partition);
	}

}
